//
//  MainscreenViewController.m
//  Palabris
//
//  Created by Administrator on 02.10.11.
//  Copyright (c) 2011 __MyCompanyName__. All rights reserved.
//

#import "MainscreenViewController.h"


@implementation MainscreenViewController


- (void)didReceiveMemoryWarning
{
    // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];
    
    // Release any cached data, images, etc that aren't in use.
}

#pragma mark - View lifecycle

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    
    [self initCustom];
}

- (void)viewDidUnload
{
    [super viewDidUnload];
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
}


- (void)dealloc
{
    [mLabelUsername release];
    [mLabelUserHighscore release];
    [mImageViewUserPicture release];
    
    [super dealloc];
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    // Return YES for supported orientations
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}


/* Custom initialization
 */
-(void)initCustom{
    
    sharedSingleton = [SingletonClass sharedInstance]; 
    
    [mLabelUsername setText:sharedSingleton.mUsername];
    [mLabelUserHighscore setText:[NSString stringWithFormat:@"%i", sharedSingleton.mUserHighscore]];
    [mImageViewUserPicture setImage:sharedSingleton.mUserImage];

    
}



////////////////////////////////////
//  Event-Buttons                 //
////////////////////////////////////

/*  Push to GameViewController
 */
-(IBAction)goGame:(id)sender{
    
    // Als erstes erstellt man ein Object vom ViewController (Page) zu der man hin will
    GameViewController *view = [[GameViewController alloc] initWithNibName:@"GameViewController" bundle:nil];
    
    // Hier bestimmt ich welche Animation der Übergang bekommt
    view.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
    
    // Hier ruft man von der NavigationController (der oberste Vater-Controller) die Push Methode, die dich zu anderen View bringt.
    [self.navigationController pushViewController:view animated:YES];
    

    [view release];
}

/*  Push to HighscoreViewController
 */
-(IBAction)goHighscore:(id)sender{
    
    // Als erstes erstellt man ein Object vom ViewController (Page) zu der man hin will
    HighscoreViewController *view = [[HighscoreViewController alloc] initWithNibName:@"HighscoreViewController" bundle:nil];
    
    // Hier bestimmt ich welche Animation der Übergang bekommt
    view.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
    
    // Hier ruft man von der NavigationController (der oberste Vater-Controller) die Push Methode, die dich zu anderen View bringt.
    [self.navigationController pushViewController:view animated:YES];
    

    [view release];
}

/*  Push to HighscoreViewController
 *
 *  !! Logout Button !!
 */
-(IBAction)goRoot:(id)sender{
    
    [self.navigationController popToRootViewControllerAnimated:YES];
}


@end
